{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_points = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n",
    "y_points = [1, 2, 3, 1, 4, 5, 6, 4, 7 , 10, 15, 9]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1e63af4dbe0>]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAOR0lEQVR4nO3db6hkd33H8c9ncxW9UUlkJ1az2b2xSNoSWiLzIJpixVgIGBIfVEi4KcEG7pOiUSxp4kLzaKFQsQoFyyWJCTisyJpWESsJUUgLdmF2E5tNNlTQ7HXjmp0Q/IP3gYZ8+mDmkux05869Z87Mmd+d9+vJmfObM3O+Z7L7yW/PnPMdJxEAoDz7mi4AAFANAQ4AhSLAAaBQBDgAFIoAB4BCLc1yZ/v378/KysosdwkAxTtx4sTLSVrD4zMN8JWVFXW73VnuEgCKZ/vMxcY5hQIAhSLAAaBQBDgAFIoAB4BCEeAAUCgCHMCe1+lIKyvSvn39ZafTdEX1mOllhAAwa52OtLYmbW7218+c6a9L0upqc3XVgRk4gD3t8OHXw3vL5mZ/vHQEOIA9bWNjd+MlIcAB7GkHD+5uvCQEOIA97cgRaXn5wrHl5f546Q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SfttnJd0v6R8lfcP2Xer/j+wTzVU4OW6lB4BCcQoFAApFgANAoQhwACgUAQ4AhSLAAaBQBDgAFIoAB4BC/R8wag+qWSMVqwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x_points, y_points, 'bo')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [],
   "source": [
    "true_slope = 10.889\n",
    "true_intercept = 3.456\n",
    "x_points = np.arange(0.0,10.0)\n",
    "y_points = true_slope * x_points + true_intercept + 0.0 * np.random.rand(len(x_points))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1e63d04f208>]"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAP6ElEQVR4nO3dX4hkZ5nH8e/TGYNWRJKYVuJMuiuyg38QJNJINCCL44X/MLkwoFvrDhKoG1fjH9BoX+xVg4L4Z2ERikR3lj24yhhIEHFXYpZlL3awJ5HVOO4mRLszZjQta1RsWA159uLUbHdPejJTfar6dL31/UB4+zx1qs/DIfObd86pek9kJpKkssy13YAkafwMd0kqkOEuSQUy3CWpQIa7JBXoUNsNAFx33XXZ7XbbbkOSpsrp06d/nZnzu712IMK92+2yurradhuSNFUiYu1ir3lZRpIKZLhLUoEMd0kqkOEuSQUy3CWpQIa7JLWgqqDbhbm5eqyq8f7+A/FR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c7FT6+ZjIqpCZ+R3gO5P43ZKkS5vKb6hKkp5fCeE+aLuBA8bzsZPnY4vnYqeiz8fYb6hKktpXwsxdknQBw12SCjTV4b4fq09Og4i4ISIejIgzEfFIRNzZdk8HQURcEREPR8S32+6lbRFxdUScjIifDv8/eVPbPbUlIj42/HPy44j4ekS8sO2eJmFqw93VJ3d4BvhEZr4GuBn40Ayfi+3uBM603cQB8WXgu5n5auD1zOh5iYjDwEeApcx8HfV3cd7XbleTMbXhjqtP/r/MPJeZDw1//j31H9znLNY2SyLiCPAu4O62e2lbRLwEeAtwD0Bm/jEzn263q1YdAl40/DZ9h0KXR5nmcL+s1SdnTUR0gZuAU+120rovAZ8Enm27kQPglcAG8LXhZaq7I+KqtptqQ2b+Avg8sA6cA36bmf/SbleTMc3hflmrT86SiHgx8C3go5n5u7b7aUtEvBt4KjNPt93LAXEIeAPwlcy8CfgDMJP3qCLiGup/4d8IvAK4KiL+st2uJmOaw93VJ7eJiBdQB3uVmfe23U/LbgHeExE/p75c99aI+Md2W2rVWeBsZp7/19xJ6rCfRW8DfpaZG5n5J+Be4M0t9zQR0xzuPwCORsSNEXEl9U2R+1vuqRUREdTXU89k5hfa7qdtmfnpzDySmV3q/y++n5lFzs4uR2b+EngiIl41LB0DftJiS21aB26OiM7wz80xCr25PJGFw/bDXlafLNgtwAeAH0XED4e1zwwXcJMAPgxUw4nQ48AHW+6nFZl5KiJOAg9Rf8rsYQpdhsDlBySpQNN8WUaSdBGGuyQVyHCXpAIZ7pJUIMNdkgpkuEtSgQx3SSrQ/wEi//kUvK2X+wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x_points, y_points, 'bo')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {},
   "outputs": [],
   "source": [
    "# y = mx + b\n",
    "m = 0\n",
    "b = 0\n",
    "y = lambda x : m*x + b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 0, 0, 0, 0, 0, 0, 0, 0]"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "x_values = [i for i in range(0, int(len(x_points))-1)]\n",
    "x_values\n",
    "\n",
    "y_values = [y(x) for x in x_values]\n",
    "y_values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_line(y, data_points):\n",
    "    x_values = [i for i in range(0, int(len(x_points))-1)]\n",
    "    y_values = [y(x) for x in x_values]\n",
    "    plt.plot(x_values, y_values, 'r')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAPEklEQVR4nO3cf6zdd13H8eeLXjbYkP3soLSrd2YNpmgy8KQTUbIwNroIdNH90Rm1MZj6BzMMYnRIzGDwBxh0iwFJmm1aEDfmYKERtJSNxR/B0dNtBsoYLeVHL5uspHNYUWbh7R/323m5ntJ7e872vZfP85Hc3PP9nM/9nnea2z7v+Z5zm6pCktSuZ/U9gCSpX4ZAkhpnCCSpcYZAkhpnCCSpcVN9D3Ayzj333Jqenu57DElaVvbs2fPtqlo5f31ZhmB6eprhcNj3GJK0rCT5+qh1Lw1JUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUu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Vv246q7BfxT4cFV9rO955usuJdwLbOx5lFcAr++uxd8OvCrJX/U70v+pqke6z48BdzF7qbRvM8DMnGdzdzIbhqXiCuD+qvpW34N0Xg18taoOVdX/AB8DfmFSJ28lBLuBdUku6Eq/GdjR80xLWvei7C3AQ1X1p33Pc0ySlUnO7G4/l9m/IF/qc6aqemtVramqaWa/t+6pqon9tDaOJKd3L/bTXXq5HOj9HWpV9W/AwSQv7pYuBXp/88YcV7NELgt1vgH8fJLTur+blzL7ut1ETE3qREtZVR1Ncg2wE1gB3FpVe3seC4AktwGXAOcmmQGur6pb+p0KmP0p9zeAz3fX4wH+sKo+2eNMAKuA7d07Op4F3FFVS+rtmkvMC4C7Zv/tYAr466r6+35HesrvAh/ufjg7APxWz/MAkOQ0Zt9h+Dt9z3JMVd2X5E7gfuAo8AAT/O8mmnj7qCTp+Fq5NCRJOg5DIEmNMwSS1DhDIEmNMwSS1DhDIEmNMwSS1Lj/BZND4gnG48lZAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_line(y, x_points)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$m = m - \\alpha \\frac{1}{k} \\sum_{i=1}^{k} (f(x^{i}) - y^{i})$$\n",
    "$$b = b - \\alpha \\frac{1}{k} \\sum_{i=1}^{k} ((f(x^{i}) - y^{i}) * x^{i})$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn = .003 # .001, .01, .1, 1 ..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [],
   "source": [
    "def summation(y, x_points, y_points):\n",
    "    total1 = 0\n",
    "    total2 = 0\n",
    "    \n",
    "    for i in range(1, len(x_points)):\n",
    "        total1 += y(x_points[i]) - y_points[i]\n",
    "        total2 += (y(x_points[i]) - y_points[i]) * x_points[i]\n",
    "        \n",
    "    return total1 / len(x_points), total2 / len(x_points)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "11.14083569719623 1.8645660782670452\n",
      "11.140788103029347 1.8654631679435751\n",
      "11.1407324674531 1.8663584779992313\n",
      "11.140669502032871 1.8672521217980165\n",
      "11.140599855964787 1.8681442027917181\n",
      "11.140524121542109 1.8690348153886558\n",
      "11.140442839142512 1.869924045746288\n",
      "11.140356501778252 1.870811972494349\n",
      "11.140265559247537 1.8716986673946079\n",
      "11.140170421922045 1.8725841959428007\n",
      "11.140071464202482 1.8734686179178075\n",
      "11.13996902767128 1.874351987882696\n",
      "11.139863423968968 1.8752343556418505\n",
      "11.139754937418457 1.8761157666580364\n",
      "11.139643827419295 1.8769962624329104\n",
      "11.139530330632102 1.8778758808541811\n",
      "11.139414662971525 1.8787546565123414\n",
      "11.139297021424543 1.8796326209896426\n",
      "11.139177585709385 1.8805098031237393\n",
      "11.139056519789062 1.8813862292482284\n",
      "11.138933973252247 1.8822619234121059\n",
      "11.138810082573116 1.8831369075799878\n",
      "11.138684972260785 1.8840112018147848\n",
      "11.138558755907988 1.8848848244443643\n",
      "11.138431537147856 1.8857577922136066\n",
      "11.13830341052683 1.8866301204231337\n",
      "11.138174462301075 1.887501823055879\n",
      "11.138044771163079 1.8883729128925637\n",
      "11.137914408904587 1.8892434016170523\n",
      "11.137783441021414 1.8901132999124743\n",
      "11.137651927265265 1.8909826175489215\n",
      "11.137519922147176 1.8918513634634584\n",
      "11.137387475396835 1.89271954583312\n",
      "11.137254632381659 1.8935871721415134\n",
      "11.137121434489117 1.8944542492395788\n",
      "11.136987919475564 1.8953207834010288\n",
      "11.13685412178449 1.896186780372926\n",
      "11.136720072836882 1.8970522454218284\n",
      "11.136585801296134 1.8979171833758914\n",
      "11.13645133330974 1.8987815986632788\n",
      "11.136316692729803 1.8996454953472064\n",
      "11.136181901314218 1.9005088771579166\n",
      "11.13604697891022 1.9013717475218483\n",
      "11.135911943621853 1.9022341095882513\n",
      "11.135776811962742 1.903095966253468\n",
      "11.135641598995505 1.9039573201830866\n",
      "11.135506318458917 1.904818173832153\n",
      "11.135370982883947 1.9056785294636107\n",
      "11.135235603699611 1.9065383891651257\n",
      "11.135100191329565 1.9073977548644352\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAATIElEQVR4nO3dfYxddZ3H8feXFiy0WApMEfuwrdkKPiQuMDEohhjQRMQAUdngrt1aIUXFBRWWB5OVJdEEsiz4EMU0xdqNIBokgbiuLEHIZmMsO1PMKnaVJykVhHGRZ6W0/e4f97admXunnd6HOfec834lk5lz5s7MNxf66ae/Off8IjORJFXLAUUPIEnqPcNdkirIcJekCjLcJamCDHdJqqDZRQ8AcOSRR+ayZcuKHkOSSmV0dPQPmTnU7nMDEe7Lli1jZGSk6DEkqVQi4rGpPueyjCRVkOEuSRVkuEtSBRnuklRBhrskVdBAXC0jSXUT0Xqul/dxtLlL0gxrF+x7O98Jw12SKmif4R4R34qIpyPil+POHR4Rd0XEg833C5rnIyK+GhEPRcT/RMTx/RxektTedJr7t4H3TTp3OXB3Zq4A7m4eA5wGrGi+rQFu6M2YkqT9sc9wz8z/BJ6ZdPpMYEPz4w3AWePO/2s2/Aw4LCKO7tWwkqTp6XTN/ajMfBKg+X5h8/wi4PFxj9vaPNciItZExEhEjIyNjXU4hiSVz1RXxQzy1TLtftfbdtzMXJuZw5k5PDTU9qZmklRZma1vvdRpu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okXEa4GTgRsBMnNbZj5b7FSFmg0cHBGzgUNoc0vyKihzuLvjUxsRsQw4DthY7CSF+zJwKbCz6EEGwBuAMWB9c5lqXUTMLXqoImTm74BrgS3Ak8BzmfkfxU7VH2UO92nt+FQnETEP+AHwmcx8vuh5ihIRHwCezszRomcZELOB44EbMvM44CWglr+jiogFNP6Fvxx4PTA3Ij5a7FT9UeZwn9aOT3UREQfSCPabMvO2oucp2EnAGRHxWxrLdadExHeKHalQW4GtmbnrX3O30gj7OnoP8GhmjmXmq8BtwDsLnqkvyhzu7vjUFBFBYz11c2ZeV/Q8RcvMKzJzcWYuo/H/xU8ys5LtbDoy8/fA4xFxTPPUqcCvChypSFuAEyPikOafm1Op6C+X+7JZx0xwx6cJTgJWAr+IiJ83z32+uWmKBPD3wE3NIvQIsLrgeQqRmRsj4lZgE42rzO6norch8PYDklRBZV6WkSRNwXCXpAoy3CWpggx3Saogw12SKshwl6QKMtwlqYL+H4Npff4wZfmKAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "for i in range(50):\n",
    "    s1, s2 = summation(y, x_points, y_points)\n",
    "    #print (s1,s2)\n",
    "    m = m - learn * s2\n",
    "    b = b - learn * s1\n",
    "    print(m,b)\n",
    "    plot_line(y, x_points)\n",
    "    plt.plot(x_points, y_points, 'bo')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "11.51523584084535"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.211157979120578"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot_line(y, x_points)\n",
    "plt.plot(x_points, y_points, 'bo')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "m = 0\n",
    "b = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv('chirps.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_points = df['Chirps'].tolist()\n",
    "y_points = df['Temp'].tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.plot(x_points, y_points, 'bo')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn = .001"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(1000):\n",
    "    s1, s2 = summation(y, x_points, y_points)\n",
    "    m = m - learn * s2\n",
    "    b = b - learn * s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.plot(x_points, y_points, 'bo')\n",
    "plot_line(y, x_points)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "y(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {
   "environment": null,
   "summary": "Learn how to apply gradient descent on a data set",
   "url": "https://anaconda.org/benawad/gradient-descent"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
